//
//  RepayMScrollViewTableViewCell.m
//  OneCreditTreasure
//
//  Created by iOS Grouper on 16/8/29.
//
//

#import "RepayMScrollViewTableViewCell.h"
#import "RepayCollectionViewCell.h"

@interface RepayMScrollViewTableViewCell ()<UICollectionViewDelegate,UICollectionViewDataSource>{
    UICollectionView *myCollectionView;
}
@end

@implementation RepayMScrollViewTableViewCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self creatView];
        
    }
    
    return self;
}


- (void)creatView{
    _titleCarL = [UILabel new];
    [self.contentView addSubview:_titleCarL];
    [_titleCarL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20 * AUTO_HEIGHT);
        make.left.mas_equalTo(20 * AUTO_WIDTH);
        make.height.mas_equalTo(15 * AUTO_HEIGHT);
        
    }];
    _titleCarL.text = @"保时捷-Boxster";
    _titleCarL.font = [UIFont fontWithName:ZIXING size:14 * AUTO_HEIGHT];
    
    
     UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    layout.itemSize = CGSizeMake(100 * AUTO_WIDTH, 80 * AUTO_HEIGHT);
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
//    layout.sectionInset = UIEdgeInsetsMake(20 * AUTO_WIDTH , 20 * AUTO_HEIGHT, 20 * AUTO_WIDTH, 20 * AUTO_HEIGHT);
    layout.minimumLineSpacing = 10 * AUTO_HEIGHT;
    layout.minimumInteritemSpacing = 10 * AUTO_WIDTH;
    myCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(20, 40 * AUTO_HEIGHT, kScreenW, 100 * AUTO_HEIGHT) collectionViewLayout:layout];

    [self.contentView addSubview:myCollectionView];
    myCollectionView.backgroundColor = [UIColor whiteColor];
    myCollectionView.showsHorizontalScrollIndicator = NO;
    myCollectionView.delegate = self;
    myCollectionView.dataSource = self;
    [myCollectionView registerClass:[RepayCollectionViewCell class] forCellWithReuseIdentifier:@"RepayCollectionViewCell"];
    
    
   }

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 6;
}


//- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
//{
//    return UIEdgeInsetsMake(5  * AUTO_WIDTH, 5 * AUTO_HEIGHT, 5 * AUTO_WIDTH, 5 * AUTO_HEIGHT);
//}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    RepayCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"RepayCollectionViewCell" forIndexPath:indexPath];
    return cell;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
